package cn.com.xjnt.vas.ordering.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.frameworks.core.repository.BaseRepository;
import com.frameworks.core.service.AbstractBaseService;

import cn.com.xjnt.vas.ordering.domain.entity.User;
import cn.com.xjnt.vas.ordering.domain.entity.UserInfo;
import cn.com.xjnt.vas.ordering.repository.UserInfoRepository;
import cn.com.xjnt.vas.ordering.repository.UserRepository;
import cn.com.xjnt.vas.ordering.service.UserInfoService;

/** 
* 类说明：
* @author 作者 LUXIN
* @version 创建时间：2016年5月11日11:48:01
*/
@Service
@Transactional
public class UserInfoServiceImpl extends AbstractBaseService<UserInfo, Long> implements UserInfoService {
    @Autowired
    private UserInfoRepository userInfoRepository;
    @Autowired
    private UserRepository userRepository;
    @Override
    protected BaseRepository<UserInfo, Long> getBaseRepository() {
        return userInfoRepository;
    }

    @Override
    public void save(UserInfo entity) {
        User user = entity.getUser();
        userRepository.save(user);
        entity.setUser(user);
        super.saveOrUpdate(entity);
    }

    @Override
    public void update(UserInfo entity) {
        User user = entity.getUser();
        userRepository.save(user);
        entity.setUser(user);
        super.saveOrUpdate(entity);
    }
}
 